package cn.doit.scala.day02.list

/**
 * @DATE 2021/12/25/14:05
 * @Author MDK
 * @Version 2021.2.2
 *
 *          1)ls(index)取值
 *          2)head第一个元素
 *          3)tail除第一个元素之外的其他元素的集合
 *          4)contains是否包含
 *          5).::("hello")  ele+:ls  ls+:ele(矢量)  .:::()  ++:
 *          6)last最后一个元素
 *
 * */
object C01_List01 {
  def main(args: Array[String]): Unit = {
    val list: List[String] = List[String]("a", "b", "c", "d")
    val list01 = 11 :: 22 :: 33 :: 44 :: 55 :: Nil

    //取值
    println(list(0))
    list.length
    list.size

    val head: String = list.head
    println(head)
    val last: String = list.last
    println(last)

    println("-------------------------------")
    println(list01.head)
    val tail = list.tail
    println(tail)

    println("-------------------------------")
    println(list.contains("b"))

    println("-------------------------------")
    val res: String = "hello" + list
    val res2: String = list + "hello"
    println(res)
    println(res2)
    println("-------------------------------")

    val res3: List[String] = list.:::(List("jin", "tom"))
    val res4: List[String] = List("jin", "tom") ++: list
    val seq = list +: "cc"
    val seq2 = list :+ "cc"

    println(seq)
    println(seq2)

  }
}
